#ifndef APPDATA_H
#define APPDATA_H

#include "Event.h"
#include "Slider.h"
#include "Wimp.h"

#include "appglobal.h"
#include "control.h"

typedef enum {
  icon_Draggable = 0,
  icon_Message,
  icon_Filename,
  icon_Next,
  icon_Cancel,
  icon_Slider1,
  icon_Slider2,
  icon_Back,

  icon_NumIcons
} install_icons_t;

typedef struct {
  window_handle win, proginfo;
  menu_ptr menu;
  control_master_data *control;

  /* Help messages */
  char *background_help;
  char *icon_help[icon_NumIcons];
  /* Icons 0 and 1 may have help switched on and off, so store it here */
  char *draggable_help;
  char *message_help;

  /* Which handlers are registered for location dragging */
  /*
  struct {
    BOOL drag_in;
    BOOL drag_out;
    BOOL click_next;
  } handlers;
  */
  int datasave_ref;

  slider_info *disc_slider;
  slider_info *total_slider;

  event_handler next_handler;
  event_handler back_handler;

  BOOL lowmem;  /* If < 8MB free, use slower, frugal bunzip2 -s option */
} app_data;

app_data *app_data_new(void);

/* Shows a message in the main message icon */
void app_data_show_message(const app_data *, const char *message);
void app_data_blank_message(const app_data *);

void app_data_set_filename_text(const app_data *, const char *text);

/* Toggle whether the status/filename field is writable */
void app_data_filename_writable(const app_data *, BOOL writable);

/* Look up fixed help messages */
void app_data_lookup_help(app_data *);

void app_data_toggle_message_help(app_data *, BOOL);

/* Whether draggable icon has null or draggable button type,
   and corresponding help message */
void app_data_toggle_draggable(app_data *, BOOL);

void app_data_shade_next(app_data *, BOOL);
void app_data_shade_back(app_data *, BOOL);

void app_data_set_draggable_icon(app_data *, const char *sprite_name);

BOOL app_data_create_sliders(app_data *);

/* Shows a status message looked up from Messages,
   eg "decompressing foo", for item foo */
void app_data_show_item_status(app_data *app, const char *token,
                               const char *item_name);

/* Registers handlers for click on Next or Back button, remembering them
   so that they can easily be deregistered */
void app_data_set_next_handler(app_data *app, event_handler handler);
void app_data_set_back_handler(app_data *app, event_handler handler);
void app_data_release_handlers(app_data *app);


#endif /* APPDATA_H */
